<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=device-width, initial-scale=1" />
		<script th:src="@{/static/js/jquery.min.js}" type="text/javascript" charset="utf-8"></script>
		<script th:src="@{/static/js/afquery.js}" type="text/javascript" charset="utf-8"></script>
		<script th:src="@{/static/layui/layui.all.js}" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" th:href="@{/static/layui/css/layui.css}" />
		<link rel="stylesheet" type="text/css" th:href="@{/static/css/Common.css}" />
	</head>
	<body>
		<!-- 对话框面板定义 -->
		<div class='assess_dlg_define' style='display:none'>
			<div class='pane' style='padding:10px;overflow-y: scroll;'>
				<div style='padding:10px'>
					<div th:each = "row : ${QuestionList}" style="margin-top: 10px;">
						<div style="background-color: rgba(176,196,222,0.2)"><span>问题[[${rowStat.index}+1]]：</span><span th:text="${row.question}"></span></div>
						<div style="margin-top: 10px;">
							<span class="select_button">非常满意<input type="radio" th:name="${rowStat.index}" value="1" title="非常满意"></span>
							<span class="select_button">满意<input type="radio" th:name="${rowStat.index}" value="0.8" title="满意"></span>
							<span class="select_button">一般<input type="radio" th:name="${rowStat.index}" value="0.6" title="一般"></span>
							<span class="select_button">不满意<input type="radio" th:name="${rowStat.index}" value="0.4" title="不满意"></span>
							<span class="select_button">非常不满意<input type="radio" th:name="${rowStat.index}" value="0.2" title="非常不满意"></span>
						</div>
					</div>
					 
				</div>
			</div>
		</div>
		
		<div class="layui-row" id="Main" style="height: 100%;overflow: hidden;">
			<!-- 顶部区 -->
			<div th:replace =" ~{A_Common::Top_Menu}"></div>
			
			<!-- 左侧菜单区 -->
			<div th:replace =" ~{A_Common::Left_Menu}"></div>
			
			<!-- 右侧内容区 -->
			<div th:fragment="Role_Manager" class="layui-col-xs8 layui-col-md10 layui-row" id="right_Content">
				<fieldset class="layui-elem-field site-demo-button" style="padding: 5%;">
					<legend>评价管理</legend>
					 <div class="layui-form">
						<!-- <div class="layui-form-item">
						    <div class="layui-inline">
						      <label class="layui-form-label">姓名</label>
						      <div class="layui-input-inline">
						        <input type="text" class="layui-input" disabled="true">
						      </div>
						    </div>
						    <div class="layui-inline">
						      <label class="layui-form-label">学号</label>
						      <div class="layui-input-inline">
						        <input type="text" class="layui-input" disabled="true">
						      </div>
						    </div>
						    <div class="layui-inline">
						      <label class="layui-form-label">班级</label>
						      <div class="layui-input-inline">
						        <input type="text" class="layui-input" disabled="true">
						      </div>
						    </div>
							<div class="layui-inline">
							  <label class="layui-form-label">日期</label>
							  <div class="layui-input-inline">
							    <input type="text" class="layui-input" disabled="true">
							  </div>
							</div>
							
						  </div> -->
					 </div>
					 <div id="">
						 
					 	<table class="layui-table">
					 		<colgroup>
					 			<col width="60">
					 			<col>
								<col width="100">
								<col width="80">
					 		</colgroup>
					 		<thead>
					 			<tr>
					 				<th>序号</th>
					 				<th>课程</th>
									<th>教师</th>
									<th>操作</th>
					 			</tr>
					 		</thead>
					 		<tbody>
					 			<tr th:each="row : ${CourseTeacherList}">
					 				<td th:text="${rowStat.index}+1">1</td>
					 				<td th:text="${row.CourseName}">阿里巴巴</td>
									<td th:text="${row.RealName}">姓名</td>
									<td th:idd = "${row.teacher_id}" onclick="openAddAssess(this)">评价</td>
					 			</tr>
					 		</tbody>
					 	</table>
					 	<!-- <div class="nothing">
					 							没有查询到有用数据
					 						</div> -->
					 </div>
				</fieldset>
			</div>
		</div>
	</body>
	<!-- 初始化点击事件 -->
	<script th:replace =" ~{A_Common::Init_Click}"></script>
	<script th:inline="javascript">
		
		var QuestionList = [[${QuestionList}]];
		layui.use('form', function(){
		  var form = layui.form;
		  
		  //监听提交
		  form.on('submit(formDemo)', function(data){
		    layer.msg(JSON.stringify(data.field));
		    return false;
		  });
		});
		function openAddAssess(e){
			if($(e).text() == '已评教'){
				return;
			}
			 var dlgContent = $('.assess_dlg_define').html(); // 窗口内容
			layer.open({
				type: 1,
				title: '添加记录', 
				area: ['600px', '400px'], 
				content: dlgContent,
				btn:['确定','放弃'] ,
				success: function(){
				},
				
				btn1: function(index,layero){
					//参评人点评选项
					var SingularList = new Array();
					for(let i=0;i<QuestionList.length;i++){
						let S = $(".pane .select_button input[name="+i+"]:checked").val();
						if(S == null){
							continue;
						}
						SingularList.push(S);
					}
					if(SingularList.length != QuestionList.length){
						layer.open({
							title: "信息",
							content: '请填写完整！',
							offset: 't',
							time: 500
						});
					}else{
						
						let Point = 100/SingularList.length;
						let req = {};
						req.Point = 0;
						for(let i = 0;i<SingularList.length;i++){  
							req.Point += Point * SingularList[i];
						}
						req.Role = [[${datas.jobj.role}]];
						req.Appraisee = $(e).attr("idd");//教师表的id
						req.Appraiser = [[${datas.jobj.userId}]];
						req.AS_id = QuestionList[0].as_id;
						
						Af.rest([[@{AJ_saveAssess.do}]],req,function(data){
							layer.open({
								title: "信息",
								content: '成功！',
								offset: 't',
								time: 500,
								success: function(layero, index){
									setTimeout(function(){location.reload();},600);
								  } 
							});
						});
						// 关闭对话框
						layer.close(index);
					}				
				},
				btn2 : function(index,layero){
					layer.close(index)		
				}
			});	
		
	}
	
	M.inits = function(){
		let TeacheredList = [[${TeacheredList}]];
		let trs = $(".layui-table tbody tr");
		for(let i = 0;i<TeacheredList.length;i++){
			for(let j=0;j<trs.length;j++){
				if(TeacheredList[i] == $($(trs).get(j)).find("td:eq(3)").attr("idd")){
					$($(trs).get(j)).find("td:eq(3)").text("已评教");
				}
			}
		}
	}();
		
		var page = sessionStorage.getItem("page");
	</script>
</html>
